$(function () {

    var BASE_URL = "https://dc-api.rupee-mama.in";

    new Common();

    function Common() {

        this.init=function () {

            this.applyNowBtn=$(".showQrCodeBtn");
            this.qrCodeModal=$("#qrCode-modal");
            this.closeModalBtn=$("#qrCode-modal .close");

            this.getProtocolUrl();

            this.bind();

        };

        this.bind=function () {

            var self=this;

            self.applyNowBtn.bind('click',function () {
                self.qrCodeModal.show();
            });

            self.closeModalBtn.bind('click',function () {
                self.qrCodeModal.hide();
            })

        };

        this.getProtocolUrl = function () {
            $.ajax({
                type: "POST",
                url: BASE_URL + '/config/protocol/get',
                headers: {
                    "Content-Type": "application/json"
                },
                dataType: 'json',
                success: function (json) {
                    if (json.code === 0) {
                        $("#footer_privacyPolicy").attr("href", json.data.privacyPolicy);
                        $("#footer_registerProtocol").attr("href", json.data.registerProtocol);
                    }
                }
            })
        };

        this.init();
    }; 
})

$(".navbar").find(".nav-item.active").removeClass("active") 
$(".navbar").find(`.nav-link[href='${window.location.pathname}']`).parent().addClass("active")
$(".navbar .nav-link").on("click",function () {
    $(this).parent().addClass("active")
}) 